package com.dearbinge.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class PageResult<T> implements Serializable {
    private static final long serialVersionUID = -8768394249170248688L;
    private List<T> data;
    private List<Object> objectData;
    private List<Map<String,Object>> mapList;
    private Long total;
    private Integer maxPageSize;
    private Integer statusCode;
    private String msg;
    private T data1;

    public PageResult(List<T> data, Long total) {
        this.data = data;
        this.total = total;
    }

    public PageResult(List<Object> objectData,Integer maxPageSize) {
        this.objectData = objectData;
    }

    public PageResult(List<Map<String,Object>> mapList) {
        this.mapList = mapList;
    }

    public PageResult() {
        this.data = new ArrayList();
        this.total = 0L;
    }

    public PageResult(Integer statusCode,T data1,String msg) {
        this.statusCode = statusCode;
        this.msg = msg;
    }

    public static <T> PageResult<T> ok(T result) {
        return new PageResult(200, result, "");
    }

    /**
     * 返回异常提示
     *
     * @param msg 提示
     * @param <T> 类
     * @return 结果
     */
    public static <T> PageResult<T> error(Integer code, String msg) {
        return new PageResult(code, (Object)null, msg);
    }

    public List<T> getData() {
        return this.data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Long getTotal() {
        return this.total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Integer getMaxPageSize() {
        return maxPageSize;
    }

    public void setMaxPageSize(Integer maxPageSize) {
        this.maxPageSize = maxPageSize;
    }

    public List<Map<String, Object>> getMapList() {
        return mapList;
    }

    public void setMapList(List<Map<String, Object>> mapList) {
        this.mapList = mapList;
    }

    public List<Object> getObjectData() {
        return objectData;
    }

    public void setObjectData(List<Object> objectData) {
        this.objectData = objectData;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData1() {
        return data1;
    }

    public void setData1(T data1) {
        this.data1 = data1;
    }
}
